import event

class EventIt:
    def next(self):
        raise StopIteration

class EventProducer:
    def __init__(self, e_it_class = EventIt):
        self.e_it_class = e_it_class
        self.oneshot_events = []
    def __iter__(self):
        it = self.e_it_class(self.oneshot_events)
        self.oneshot_events = []
        return it
    def add_oneshot_event(self, h_event):
        self.oneshot_events.append(h_event)

import pygame

class ClientEventIt:
    pg_e_trans = event.PygameEventTranslator()
    fix_events = [event.FrameEvent]
    def __init__(self, events):
        self.events = []
        for e in pygame.event.get():
            t_e = self.pg_e_trans.translate(e)
            if t_e:
                self.events.append(t_e)
        self.events += [e_class() for e_class in self.fix_events]
        self.events += events
        self.it = self.events.__iter__()
    def next(self):
        return self.it.next()
    
class ServerEventIt:
    fix_events = [event.FrameEvent]
    def __init__(self, events):
        self.events = []
        self.events += [e_class() for e_class in self.fix_events]
        self.events += events
        self.it = self.events.__iter__()
    def next(self):
        return self.it.next()